<?php
    include('./config.php');
    include('./request.php');
    $username = $result->username;
    try{
        if($username==""){
            echo "noLogin";
        }else{
        $pdo = new PDO($dsn,$user,$pass);
        $sql = "select market_name,market_type,market_author,market_email,market_phone from market where market_name=(select supermarket.market_name from user,supermarket where user.user_id = supermarket.user_id and user.user_name='".$username."')";
        $res = $pdo->prepare($sql);
        $res->execute();
        $rea = $res->fetch(PDO::FETCH_ASSOC);
        if($rea['market_name']!=""){
            $arr = array('marketName'=>$rea['market_name'],'marketType'=>$rea['market_type'],'marketAuthor'=>$rea['market_author'],'marketEmail'=>$rea['market_email'],'marketPhone'=>$rea['market_phone']);
            echo json_encode($arr);
        }else{
            $arr = array('marketName'=>"",'marketType'=>"",'marketAuthor'=>"",'marketEmail'=>"",'marketPhone'=>"");
            // echo json_encode($arr);
            echo $rea['market_name'];
        }
      }
    }catch(PDOException $e){
        echo "error";
    }
?>